#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    timer = new QTimer(this) ;
    connect(timer ,&QTimer::timeout , this , &Widget::handle) ;
     timer->start(100) ;//设置定时器每100毫秒触发一次超时信号
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handle()
{
    //获得进度条的当前数值
         int value = ui->progressBar->value();
             //进度条满了就停止定时器
                 if(value>=100)
                     {
                             timer->stop();
                                     return ;
                                            }
    
                                                 ui->progressBar->setValue(value+1) ;
    
                                                 }
    
    
